function showtip(a) {
    $("#div_tip").html(a);
    $("#div_tip").show();
    $("#div_tip").fadeOut(5e3)
}

function request() {
    video_url = $("#input_url").val();
    if (!is_url(video_url)) {
        showtip("无效网址");
        return
    }

    function encrypt() {
        var a = "-----BEGIN PUBLIC KEY-----                MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyDR+V/DU0CyYWakhPSjLwWVmC                mMqo3uugmVXPitly7BqltGDW0c1PbcQ4Y+O/lukAa3qBvxEGqwhZSQokUCQ/mCHt                FfmwlGmhHpSLZKKtPVOCKyZGCW6JdQs2ijKVgmks3jxSQ0ceeTrKU6f4KWL89DYq                CTqExJISjSAq5MAarQIDAQAB                -----END PUBLIC KEY-----";
        var b = RSA.getPublicKey(a);
        element = document.getElementById("input_url");
        return RSA.encrypt(element.value, b)
    }

    function LoadFunction() {
        $("#list").html("加载中...")
    }

    function erryFunction() {
        showtip("链接数据超时");
        return
    }

    var c = 0;
    if ($("#label_trailer_image").hasClass("checked")) {
        c = 1
    }
    $("#button_post").attr("disabled", true);
    var d = encrypt();
    $.ajax({
        method: "post",
        data: {input_url: d, herald: c},
        url: "api.php",
        cache: false,
        timeout: 5e3,
        beforeSend: LoadFunction,
        error: erryFunction,
        success: function (a) {
            $("#button_post").attr("disabled", false);
            var b = "";
            if (a.error == 1) {
                showtip("暂不支持该站或URL格式错误！");
                b = a.it + a.url;
                console.log(a.error)
            } else if (a.error == 2) {
                b = a.it + a.url;
                showtip("出现异常,请刷新重试或通知管理员！");
                console.log(a.error)
            } else {
                $.each(a.list, function (i, n) {
                    b += n["it"] + a.keywords + n["url"] + "\n"
                })
            }
            document.getElementById("div_result").innerHTML = b
        }
    })
}

function copyTextToClipboard(a) {
    var b = document.createElement("textarea");
    b.textContent = a;
    var c = document.getElementsByTagName("body")[0];
    c.appendChild(b);
    b.select();
    document.execCommand("copy");
    c.removeChild(b)
}

function is_url(a) {
    if (a.indexOf("http://") == 0 || a.indexOf("https://") == 0) {
        return true
    }
    return false
}

function trim(a) {
    return a.replace(/(^\s*)|(\s*$)/g, "")
}

function ltrim(a) {
    return a.replace(/(^\s*)/g, "")
}

function rtrim(a) {
    return a.replace(/(\s*$)/g, "")
}

$(document).ready(function () {
    $("#button_post").click(function () {
        request()
    });
    $("#button_copy").click(function () {
        copyTextToClipboard(trim($("#div_result").html().replace(/<br>/g, "\r\n")));
        showtip("复制成功")
    });
    $("#label_trailer").hover(function () {
        $("#label_trailer_image").addClass("hover")
    }, function () {
        $("#label_trailer_image").removeClass("hover")
    });
    $("#label_trailer").click(function () {
        if ($("#label_trailer_image").hasClass("checked")) {
            $("#label_trailer_image").removeClass("checked")
        } else {
            $("#label_trailer_image").addClass("checked")
        }
        return false
    })
});
//----------------------------------------------------------------------------------------------------------------------

var RSAPublicKey = function (b, a) {
    this.modulus = new BigInteger(Hex.encode(b), 16);
    this.encryptionExponent = new BigInteger(Hex.encode(a), 16)
};
var UTF8 = {
    encode: function (d) {
        d = d.replace(/\r\n/g, "\n");
        var c = "";
        for (var b = 0; b < d.length; b++) {
            var a = d.charCodeAt(b);
            if (a < 128) {
                c += String.fromCharCode(a)
            } else {
                if ((a > 127) && (a < 2048)) {
                    c += String.fromCharCode((a >> 6) | 192);
                    c += String.fromCharCode((a & 63) | 128)
                } else {
                    c += String.fromCharCode((a >> 12) | 224);
                    c += String.fromCharCode(((a >> 6) & 63) | 128);
                    c += String.fromCharCode((a & 63) | 128)
                }
            }
        }
        return c
    }, decode: function (d) {
        var b = "";
        var c = 0;
        var a = $c1 = $c2 = 0;
        while (c < d.length) {
            a = d.charCodeAt(c);
            if (a < 128) {
                b += String.fromCharCode(a);
                c++
            } else {
                if ((a > 191) && (a < 224)) {
                    $c2 = d.charCodeAt(c + 1);
                    b += String.fromCharCode(((a & 31) << 6) | ($c2 & 63));
                    c += 2
                } else {
                    $c2 = d.charCodeAt(c + 1);
                    $c3 = d.charCodeAt(c + 2);
                    b += String.fromCharCode(((a & 15) << 12) | (($c2 & 63) << 6) | ($c3 & 63));
                    c += 3
                }
            }
        }
        return b
    }
};
var Base64 = {
    base64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (b) {
        if (!b) {
            return false
        }
        var d = "";
        var i, f, c;
        var h, g, e, a;
        var j = 0;
        do {
            i = b.charCodeAt(j++);
            f = b.charCodeAt(j++);
            c = b.charCodeAt(j++);
            h = i >> 2;
            g = ((i & 3) << 4) | (f >> 4);
            e = ((f & 15) << 2) | (c >> 6);
            a = c & 63;
            if (isNaN(f)) {
                e = a = 64
            } else {
                if (isNaN(c)) {
                    a = 64
                }
            }
            d += this.base64.charAt(h) + this.base64.charAt(g) + this.base64.charAt(e) + this.base64.charAt(a)
        } while (j < b.length);
        return d
    }, decode: function (g) {
        if (!g) {
            return false
        }
        g = g.replace(/[^A-Za-z0-9\+\/\=]/g, "");
        var d = "";
        var e, c, b, a;
        var f = 0;
        do {
            e = this.base64.indexOf(g.charAt(f++));
            c = this.base64.indexOf(g.charAt(f++));
            b = this.base64.indexOf(g.charAt(f++));
            a = this.base64.indexOf(g.charAt(f++));
            d += String.fromCharCode((e << 2) | (c >> 4));
            if (b != 64) {
                d += String.fromCharCode(((c & 15) << 4) | (b >> 2))
            }
            if (a != 64) {
                d += String.fromCharCode(((b & 3) << 6) | a)
            }
        } while (f < g.length);
        return d
    }
};
var Hex = {
    hex: "0123456789abcdef", encode: function (d) {
        if (!d) {
            return false
        }
        var a = "";
        var b;
        var c = 0;
        do {
            b = d.charCodeAt(c++);
            a += this.hex.charAt((b >> 4) & 15) + this.hex.charAt(b & 15)
        } while (c < d.length);
        return a
    }, decode: function (c) {
        if (!c) {
            return false
        }
        c = c.replace(/[^0-9abcdef]/g, "");
        var a = "";
        var b = 0;
        do {
            a += String.fromCharCode(((this.hex.indexOf(c.charAt(b++)) << 4) & 240) | (this.hex.indexOf(c.charAt(b++)) & 15))
        } while (b < c.length);
        return a
    }
};
var ASN1Data = function (a) {
    this.error = false;
    this.parse = function (d) {
        if (!d) {
            this.error = true;
            return null
        }
        var c = [];
        while (d.length > 0) {
            var b = d.charCodeAt(0);
            d = d.substr(1);
            var g = 0;
            if ((b & 31) == 5) {
                d = d.substr(1)
            } else {
                if (d.charCodeAt(0) & 128) {
                    var f = d.charCodeAt(0) & 127;
                    d = d.substr(1);
                    if (f > 0) {
                        g = d.charCodeAt(0)
                    }
                    if (f > 1) {
                        g = ((g << 8) | d.charCodeAt(1))
                    }
                    if (f > 2) {
                        this.error = true;
                        return null
                    }
                    d = d.substr(f)
                } else {
                    g = d.charCodeAt(0);
                    d = d.substr(1)
                }
            }
            var e = "";
            if (g) {
                if (g > d.length) {
                    this.error = true;
                    return null
                }
                e = d.substr(0, g);
                d = d.substr(g)
            }
            if (b & 32) {
                c.push(this.parse(e))
            } else {
                c.push(this.value((b & 128) ? 4 : (b & 31), e))
            }
        }
        return c
    };
    this.value = function (f, e) {
        if (f == 1) {
            return e ? true : false
        } else {
            if (f == 2) {
                return e
            } else {
                if (f == 3) {
                    return this.parse(e.substr(1))
                } else {
                    if (f == 5) {
                        return null
                    } else {
                        if (f == 6) {
                            var c = [];
                            var k = e.charCodeAt(0);
                            c.push(Math.floor(k / 40));
                            c.push(k - c[0] * 40);
                            var g = [];
                            var h = 0;
                            var j;
                            for (j = 1; j < e.length; j++) {
                                var d = e.charCodeAt(j);
                                g.push(d & 127);
                                if (d & 128) {
                                    h++
                                } else {
                                    var i;
                                    var b = 0;
                                    for (i = 0; i < g.length; i++) {
                                        b += g[i] * Math.pow(128, h--)
                                    }
                                    c.push(b);
                                    h = 0;
                                    g = []
                                }
                            }
                            return c.join(".")
                        }
                    }
                }
            }
        }
        return null
    };
    this.data = this.parse(a)
};
var RSA = {
    getPublicKey: function (a) {
        if (a.length < 50) {
            return false
        }
        if (a.substr(0, 26) != "-----BEGIN PUBLIC KEY-----") {
            return false
        }
        a = a.substr(26);
        if (a.substr(a.length - 24) != "-----END PUBLIC KEY-----") {
            return false
        }
        a = a.substr(0, a.length - 24);
        a = new ASN1Data(Base64.decode(a));
        if (a.error) {
            return false
        }
        a = a.data;
        if (a[0][0][0] == "1.2.840.113549.1.1.1") {
            return new RSAPublicKey(a[0][1][0][0], a[0][1][0][1])
        }
        return false
    }, encrypt: function (b, c) {
        if (!c) {
            return false
        }
        var a = (c.modulus.bitLength() + 7) >> 3;
        b = this.pkcs1pad2(b, a);
        if (!b) {
            return false
        }
        b = b.modPowInt(c.encryptionExponent, c.modulus);
        if (!b) {
            return false
        }
        b = b.toString(16);
        while (b.length < a * 2) {
            b = "0" + b
        }
        return Base64.encode(Hex.decode(b))
    }, pkcs1pad2: function (a, c) {
        if (c < a.length + 11) {
            return null
        }
        var b = [];
        var d = a.length - 1;
        while (d >= 0 && c > 0) {
            b[--c] = a.charCodeAt(d--)
        }
        b[--c] = 0;
        while (c > 2) {
            b[--c] = Math.floor(Math.random() * 254) + 1
        }
        b[--c] = 2;
        b[--c] = 0;
        return new BigInteger(b)
    }
};

//----------------------------------------------------------------------------------------------------------------------

var dbits;
var canary = 244837814094590;
var j_lm = (canary & 16777215) == 15715070;

function BigInteger(e, d, f) {
    if (e != null) {
        if ("number" == typeof e) {
            this.fromNumber(e, d, f)
        } else {
            if (d == null && "string" != typeof e) {
                this.fromString(e, 256)
            } else {
                this.fromString(e, d)
            }
        }
    }
}

function nbi() {
    return new BigInteger(null)
}

function am1(f, a, b, e, h, g) {
    while (--g >= 0) {
        var d = a * this[f++] + b[e] + h;
        h = Math.floor(d / 67108864);
        b[e++] = d & 67108863
    }
    return h
}

function am2(f, q, r, e, o, a) {
    var k = q & 32767, p = q >> 15;
    while (--a >= 0) {
        var d = this[f] & 32767;
        var g = this[f++] >> 15;
        var b = p * d + g * k;
        d = k * d + ((b & 32767) << 15) + r[e] + (o & 1073741823);
        o = (d >>> 30) + (b >>> 15) + p * g + (o >>> 30);
        r[e++] = d & 1073741823
    }
    return o
}

function am3(f, q, r, e, o, a) {
    var k = q & 16383, p = q >> 14;
    while (--a >= 0) {
        var d = this[f] & 16383;
        var g = this[f++] >> 14;
        var b = p * d + g * k;
        d = k * d + ((b & 16383) << 14) + r[e] + o;
        o = (d >> 28) + (b >> 14) + p * g;
        r[e++] = d & 268435455
    }
    return o
}

if (j_lm && navigator.appName == "Microsoft Internet Explorer") {
    BigInteger.prototype.am = am2;
    dbits = 30
} else {
    if (j_lm && navigator.appName != "Netscape") {
        BigInteger.prototype.am = am1;
        dbits = 26
    } else {
        BigInteger.prototype.am = am3;
        dbits = 28
    }
}
BigInteger.prototype.DB = dbits;
BigInteger.prototype.DM = (1 << dbits) - 1;
BigInteger.prototype.DV = 1 << dbits;
var BI_FP = 52;
BigInteger.prototype.FV = Math.pow(2, BI_FP);
BigInteger.prototype.F1 = BI_FP - dbits;
BigInteger.prototype.F2 = 2 * dbits - BI_FP;
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
var BI_RC = new Array();
var rr, vv;
rr = "0".charCodeAt(0);
for (vv = 0; vv <= 9; ++vv) {
    BI_RC[rr++] = vv
}
rr = "a".charCodeAt(0);
for (vv = 10; vv < 36; ++vv) {
    BI_RC[rr++] = vv
}
rr = "A".charCodeAt(0);
for (vv = 10; vv < 36; ++vv) {
    BI_RC[rr++] = vv
}

function int2char(a) {
    return BI_RM.charAt(a)
}

function intAt(b, a) {
    var d = BI_RC[b.charCodeAt(a)];
    return d == null ? -1 : d
}

function bnpCopyTo(b) {
    for (var a = this.t - 1; a >= 0; --a) {
        b[a] = this[a]
    }
    b.t = this.t;
    b.s = this.s
}

function bnpFromInt(a) {
    this.t = 1;
    this.s = a < 0 ? -1 : 0;
    if (a > 0) {
        this[0] = a
    } else {
        if (a < -1) {
            this[0] = a + DV
        } else {
            this.t = 0
        }
    }
}

function nbv(a) {
    var b = nbi();
    b.fromInt(a);
    return b
}

function bnpFromString(h, c) {
    var e;
    if (c == 16) {
        e = 4
    } else {
        if (c == 8) {
            e = 3
        } else {
            if (c == 256) {
                e = 8
            } else {
                if (c == 2) {
                    e = 1
                } else {
                    if (c == 32) {
                        e = 5
                    } else {
                        if (c == 4) {
                            e = 2
                        } else {
                            this.fromRadix(h, c);
                            return
                        }
                    }
                }
            }
        }
    }
    this.t = 0;
    this.s = 0;
    var g = h.length, d = false, f = 0;
    while (--g >= 0) {
        var a = e == 8 ? h[g] & 255 : intAt(h, g);
        if (a < 0) {
            if (h.charAt(g) == "-") {
                d = true
            }
            continue
        }
        d = false;
        if (f == 0) {
            this[this.t++] = a
        } else {
            if (f + e > this.DB) {
                this[this.t - 1] |= (a & (1 << this.DB - f) - 1) << f;
                this[this.t++] = a >> this.DB - f
            } else {
                this[this.t - 1] |= a << f
            }
        }
        f += e;
        if (f >= this.DB) {
            f -= this.DB
        }
    }
    if (e == 8 && (h[0] & 128) != 0) {
        this.s = -1;
        if (f > 0) {
            this[this.t - 1] |= (1 << this.DB - f) - 1 << f
        }
    }
    this.clamp();
    if (d) {
        BigInteger.ZERO.subTo(this, this)
    }
}

function bnpClamp() {
    var a = this.s & this.DM;
    while (this.t > 0 && this[this.t - 1] == a) {
        --this.t
    }
}

function bnToString(c) {
    if (this.s < 0) {
        return "-" + this.negate().toString(c)
    }
    var e;
    if (c == 16) {
        e = 4
    } else {
        if (c == 8) {
            e = 3
        } else {
            if (c == 2) {
                e = 1
            } else {
                if (c == 32) {
                    e = 5
                } else {
                    if (c == 64) {
                        e = 6
                    } else {
                        if (c == 4) {
                            e = 2
                        } else {
                            return this.toRadix(c)
                        }
                    }
                }
            }
        }
    }
    var g = (1 << e) - 1, l, a = false, h = "", f = this.t;
    var j = this.DB - f * this.DB % e;
    if (f-- > 0) {
        if (j < this.DB && (l = this[f] >> j) > 0) {
            a = true;
            h = int2char(l)
        }
        while (f >= 0) {
            if (j < e) {
                l = (this[f] & (1 << j) - 1) << e - j;
                l |= this[--f] >> (j += this.DB - e)
            } else {
                l = this[f] >> (j -= e) & g;
                if (j <= 0) {
                    j += this.DB;
                    --f
                }
            }
            if (l > 0) {
                a = true
            }
            if (a) {
                h += int2char(l)
            }
        }
    }
    return a ? h : "0"
}

function bnNegate() {
    var a = nbi();
    BigInteger.ZERO.subTo(this, a);
    return a
}

function bnAbs() {
    return this.s < 0 ? this.negate() : this
}

function bnCompareTo(b) {
    var d = this.s - b.s;
    if (d != 0) {
        return d
    }
    var c = this.t;
    d = c - b.t;
    if (d != 0) {
        return d
    }
    while (--c >= 0) {
        if ((d = this[c] - b[c]) != 0) {
            return d
        }
    }
    return 0
}

function nbits(a) {
    var c = 1, b;
    if ((b = a >>> 16) != 0) {
        a = b;
        c += 16
    }
    if ((b = a >> 8) != 0) {
        a = b;
        c += 8
    }
    if ((b = a >> 4) != 0) {
        a = b;
        c += 4
    }
    if ((b = a >> 2) != 0) {
        a = b;
        c += 2
    }
    if ((b = a >> 1) != 0) {
        a = b;
        c += 1
    }
    return c
}

function bnBitLength() {
    if (this.t <= 0) {
        return 0
    }
    return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ this.s & this.DM)
}

function bnpDLShiftTo(c, b) {
    var a;
    for (a = this.t - 1; a >= 0; --a) {
        b[a + c] = this[a]
    }
    for (a = c - 1; a >= 0; --a) {
        b[a] = 0
    }
    b.t = this.t + c;
    b.s = this.s
}

function bnpDRShiftTo(c, b) {
    for (var a = c; a < this.t; ++a) {
        b[a - c] = this[a]
    }
    b.t = Math.max(this.t - c, 0);
    b.s = this.s
}

function bnpLShiftTo(j, e) {
    var b = j % this.DB;
    var a = this.DB - b;
    var g = (1 << a) - 1;
    var f = Math.floor(j / this.DB), h = this.s << b & this.DM, d;
    for (d = this.t - 1; d >= 0; --d) {
        e[d + f + 1] = this[d] >> a | h;
        h = (this[d] & g) << b
    }
    for (d = f - 1; d >= 0; --d) {
        e[d] = 0
    }
    e[f] = h;
    e.t = this.t + f + 1;
    e.s = this.s;
    e.clamp()
}

function bnpRShiftTo(g, d) {
    d.s = this.s;
    var e = Math.floor(g / this.DB);
    if (e >= this.t) {
        d.t = 0;
        return
    }
    var b = g % this.DB;
    var a = this.DB - b;
    var f = (1 << b) - 1;
    d[0] = this[e] >> b;
    for (var c = e + 1; c < this.t; ++c) {
        d[c - e - 1] |= (this[c] & f) << a;
        d[c - e] = this[c] >> b
    }
    if (b > 0) {
        d[this.t - e - 1] |= (this.s & f) << a
    }
    d.t = this.t - e;
    d.clamp()
}

function bnpSubTo(d, f) {
    var e = 0, g = 0, b = Math.min(d.t, this.t);
    while (e < b) {
        g += this[e] - d[e];
        f[e++] = g & this.DM;
        g >>= this.DB
    }
    if (d.t < this.t) {
        g -= d.s;
        while (e < this.t) {
            g += this[e];
            f[e++] = g & this.DM;
            g >>= this.DB
        }
        g += this.s
    } else {
        g += this.s;
        while (e < d.t) {
            g -= d[e];
            f[e++] = g & this.DM;
            g >>= this.DB
        }
        g -= d.s
    }
    f.s = g < 0 ? -1 : 0;
    if (g < -1) {
        f[e++] = this.DV + g
    } else {
        if (g > 0) {
            f[e++] = g
        }
    }
    f.t = e;
    f.clamp()
}

function bnpMultiplyTo(c, e) {
    var b = this.abs(), f = c.abs();
    var d = b.t;
    e.t = d + f.t;
    while (--d >= 0) {
        e[d] = 0
    }
    for (d = 0; d < f.t; ++d) {
        e[d + b.t] = b.am(0, f[d], e, d, 0, b.t)
    }
    e.s = 0;
    e.clamp();
    if (this.s != c.s) {
        BigInteger.ZERO.subTo(e, e)
    }
}

function bnpSquareTo(d) {
    var a = this.abs();
    var b = d.t = 2 * a.t;
    while (--b >= 0) {
        d[b] = 0
    }
    for (b = 0; b < a.t - 1; ++b) {
        var e = a.am(b, a[b], d, 2 * b, 0, 1);
        if ((d[b + a.t] += a.am(b + 1, 2 * a[b], d, 2 * b + 1, e, a.t - b - 1)) >= a.DV) {
            d[b + a.t] -= a.DV;
            d[b + a.t + 1] = 1
        }
    }
    if (d.t > 0) {
        d[d.t - 1] += a.am(b, a[b], d, 2 * b, 0, 1)
    }
    d.s = 0;
    d.clamp()
}

function bnpDivRemTo(n, h, g) {
    var w = n.abs();
    if (w.t <= 0) {
        return
    }
    var k = this.abs();
    if (k.t < w.t) {
        if (h != null) {
            h.fromInt(0)
        }
        if (g != null) {
            this.copyTo(g)
        }
        return
    }
    if (g == null) {
        g = nbi()
    }
    var d = nbi(), a = this.s, l = n.s;
    var v = this.DB - nbits(w[w.t - 1]);
    if (v > 0) {
        w.lShiftTo(v, d);
        k.lShiftTo(v, g)
    } else {
        w.copyTo(d);
        k.copyTo(g)
    }
    var p = d.t;
    var b = d[p - 1];
    if (b == 0) {
        return
    }
    var o = b * (1 << this.F1) + (p > 1 ? d[p - 2] >> this.F2 : 0);
    var A = this.FV / o, z = (1 << this.F1) / o, x = 1 << this.F2;
    var u = g.t, s = u - p, f = h == null ? nbi() : h;
    d.dlShiftTo(s, f);
    if (g.compareTo(f) >= 0) {
        g[g.t++] = 1;
        g.subTo(f, g)
    }
    BigInteger.ONE.dlShiftTo(p, f);
    f.subTo(d, d);
    while (d.t < p) {
        d[d.t++] = 0
    }
    while (--s >= 0) {
        var c = g[--u] == b ? this.DM : Math.floor(g[u] * A + (g[u - 1] + x) * z);
        if ((g[u] += d.am(0, c, g, s, 0, p)) < c) {
            d.dlShiftTo(s, f);
            g.subTo(f, g);
            while (g[u] < --c) {
                g.subTo(f, g)
            }
        }
    }
    if (h != null) {
        g.drShiftTo(p, h);
        if (a != l) {
            BigInteger.ZERO.subTo(h, h)
        }
    }
    g.t = p;
    g.clamp();
    if (v > 0) {
        g.rShiftTo(v, g)
    }
    if (a < 0) {
        BigInteger.ZERO.subTo(g, g)
    }
}

function bnMod(b) {
    var c = nbi();
    this.abs().divRemTo(b, null, c);
    if (this.s < 0 && c.compareTo(BigInteger.ZERO) > 0) {
        b.subTo(c, c)
    }
    return c
}

function Classic(a) {
    this.m = a
}

function cConvert(a) {
    if (a.s < 0 || a.compareTo(this.m) >= 0) {
        return a.mod(this.m)
    } else {
        return a
    }
}

function cRevert(a) {
    return a
}

function cReduce(a) {
    a.divRemTo(this.m, null, a)
}

function cMulTo(a, c, b) {
    a.multiplyTo(c, b);
    this.reduce(b)
}

function cSqrTo(a, b) {
    a.squareTo(b);
    this.reduce(b)
}

Classic.prototype.convert = cConvert;
Classic.prototype.revert = cRevert;
Classic.prototype.reduce = cReduce;
Classic.prototype.mulTo = cMulTo;
Classic.prototype.sqrTo = cSqrTo;

function bnpInvDigit() {
    if (this.t < 1) {
        return 0
    }
    var a = this[0];
    if ((a & 1) == 0) {
        return 0
    }
    var b = a & 3;
    b = b * (2 - (a & 15) * b) & 15;
    b = b * (2 - (a & 255) * b) & 255;
    b = b * (2 - ((a & 65535) * b & 65535)) & 65535;
    b = b * (2 - a * b % this.DV) % this.DV;
    return b > 0 ? this.DV - b : -b
}

function Montgomery(a) {
    this.m = a;
    this.mp = a.invDigit();
    this.mpl = this.mp & 32767;
    this.mph = this.mp >> 15;
    this.um = (1 << a.DB - 15) - 1;
    this.mt2 = 2 * a.t
}

function montConvert(a) {
    var b = nbi();
    a.abs().dlShiftTo(this.m.t, b);
    b.divRemTo(this.m, null, b);
    if (a.s < 0 && b.compareTo(BigInteger.ZERO) > 0) {
        this.m.subTo(b, b)
    }
    return b
}

function montRevert(a) {
    var b = nbi();
    a.copyTo(b);
    this.reduce(b);
    return b
}

function montReduce(a) {
    while (a.t <= this.mt2) {
        a[a.t++] = 0
    }
    for (var c = 0; c < this.m.t; ++c) {
        var b = a[c] & 32767;
        var d = b * this.mpl + ((b * this.mph + (a[c] >> 15) * this.mpl & this.um) << 15) & a.DM;
        b = c + this.m.t;
        a[b] += this.m.am(0, d, a, c, 0, this.m.t);
        while (a[b] >= a.DV) {
            a[b] -= a.DV;
            a[++b]++
        }
    }
    a.clamp();
    a.drShiftTo(this.m.t, a);
    if (a.compareTo(this.m) >= 0) {
        a.subTo(this.m, a)
    }
}

function montSqrTo(a, b) {
    a.squareTo(b);
    this.reduce(b)
}

function montMulTo(a, c, b) {
    a.multiplyTo(c, b);
    this.reduce(b)
}

Montgomery.prototype.convert = montConvert;
Montgomery.prototype.revert = montRevert;
Montgomery.prototype.reduce = montReduce;
Montgomery.prototype.mulTo = montMulTo;
Montgomery.prototype.sqrTo = montSqrTo;

function bnpIsEven() {
    return (this.t > 0 ? this[0] & 1 : this.s) == 0
}

function bnpExp(h, j) {
    if (h > 4294967295 || h < 1) {
        return BigInteger.ONE
    }
    var f = nbi(), a = nbi(), d = j.convert(this), c = nbits(h) - 1;
    d.copyTo(f);
    while (--c >= 0) {
        j.sqrTo(f, a);
        if ((h & 1 << c) > 0) {
            j.mulTo(a, d, f)
        } else {
            var b = f;
            f = a;
            a = b
        }
    }
    return j.revert(f)
}

function bnModPowInt(b, a) {
    var c;
    if (b < 256 || a.isEven()) {
        c = new Classic(a)
    } else {
        c = new Montgomery(a)
    }
    return this.exp(b, c)
}

BigInteger.prototype.copyTo = bnpCopyTo;
BigInteger.prototype.fromInt = bnpFromInt;
BigInteger.prototype.fromString = bnpFromString;
BigInteger.prototype.clamp = bnpClamp;
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
BigInteger.prototype.lShiftTo = bnpLShiftTo;
BigInteger.prototype.rShiftTo = bnpRShiftTo;
BigInteger.prototype.subTo = bnpSubTo;
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
BigInteger.prototype.squareTo = bnpSquareTo;
BigInteger.prototype.divRemTo = bnpDivRemTo;
BigInteger.prototype.invDigit = bnpInvDigit;
BigInteger.prototype.isEven = bnpIsEven;
BigInteger.prototype.exp = bnpExp;
BigInteger.prototype.toString = bnToString;
BigInteger.prototype.negate = bnNegate;
BigInteger.prototype.abs = bnAbs;
BigInteger.prototype.compareTo = bnCompareTo;
BigInteger.prototype.bitLength = bnBitLength;
BigInteger.prototype.mod = bnMod;
BigInteger.prototype.modPowInt = bnModPowInt;
BigInteger.ZERO = nbv(0);
BigInteger.ONE = nbv(1);

function bnClone() {
    var a = nbi();
    this.copyTo(a);
    return a
}

function bnIntValue() {
    if (this.s < 0) {
        if (this.t == 1) {
            return this[0] - this.DV
        } else {
            if (this.t == 0) {
                return -1
            }
        }
    } else {
        if (this.t == 1) {
            return this[0]
        } else {
            if (this.t == 0) {
                return 0
            }
        }
    }
    return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]
}

function bnByteValue() {
    return this.t == 0 ? this.s : this[0] << 24 >> 24
}

function bnShortValue() {
    return this.t == 0 ? this.s : this[0] << 16 >> 16
}

function bnpChunkSize(a) {
    return Math.floor(Math.LN2 * this.DB / Math.log(a))
}

function bnSigNum() {
    if (this.s < 0) {
        return -1
    } else {
        if (this.t <= 0 || this.t == 1 && this[0] <= 0) {
            return 0
        } else {
            return 1
        }
    }
}

function bnpToRadix(c) {
    if (c == null) {
        c = 10
    }
    if (this.signum() == 0 || c < 2 || c > 36) {
        return "0"
    }
    var f = this.chunkSize(c);
    var e = Math.pow(c, f);
    var i = nbv(e), j = nbi(), h = nbi(), g = "";
    this.divRemTo(i, j, h);
    while (j.signum() > 0) {
        g = (e + h.intValue()).toString(c).substr(1) + g;
        j.divRemTo(i, j, h)
    }
    return h.intValue().toString(c) + g
}

function bnpFromRadix(m, h) {
    this.fromInt(0);
    if (h == null) {
        h = 10
    }
    var f = this.chunkSize(h);
    var g = Math.pow(h, f), e = false, a = 0, l = 0;
    for (var c = 0; c < m.length; ++c) {
        var k = intAt(m, c);
        if (k < 0) {
            if (m.charAt(c) == "-" && this.signum() == 0) {
                e = true
            }
            continue
        }
        l = h * l + k;
        if (++a >= f) {
            this.dMultiply(g);
            this.dAddOffset(l, 0);
            a = 0;
            l = 0
        }
    }
    if (a > 0) {
        this.dMultiply(Math.pow(h, a));
        this.dAddOffset(l, 0)
    }
    if (e) {
        BigInteger.ZERO.subTo(this, this)
    }
}

function bnpFromNumber(f, e, h) {
    if ("number" == typeof e) {
        if (f < 2) {
            this.fromInt(1)
        } else {
            this.fromNumber(f, h);
            if (!this.testBit(f - 1)) {
                this.bitwiseTo(BigInteger.ONE.shiftLeft(f - 1), op_or, this)
            }
            if (this.isEven()) {
                this.dAddOffset(1, 0)
            }
            while (!this.isProbablePrime(e)) {
                this.dAddOffset(2, 0);
                if (this.bitLength() > f) {
                    this.subTo(BigInteger.ONE.shiftLeft(f - 1), this)
                }
            }
        }
    } else {
        var d = new Array(), g = f & 7;
        d.length = (f >> 3) + 1;
        e.nextBytes(d);
        if (g > 0) {
            d[0] &= (1 << g) - 1
        } else {
            d[0] = 0
        }
        this.fromString(d, 256)
    }
}

function bnToByteArray() {
    var b = this.t, c = new Array();
    c[0] = this.s;
    var e = this.DB - b * this.DB % 8, f, a = 0;
    if (b-- > 0) {
        if (e < this.DB && (f = this[b] >> e) != (this.s & this.DM) >> e) {
            c[a++] = f | this.s << this.DB - e
        }
        while (b >= 0) {
            if (e < 8) {
                f = (this[b] & (1 << e) - 1) << 8 - e;
                f |= this[--b] >> (e += this.DB - 8)
            } else {
                f = this[b] >> (e -= 8) & 255;
                if (e <= 0) {
                    e += this.DB;
                    --b
                }
            }
            if ((f & 128) != 0) {
                f |= -256
            }
            if (a == 0 && (this.s & 128) != (f & 128)) {
                ++a
            }
            if (a > 0 || f != this.s) {
                c[a++] = f
            }
        }
    }
    return c
}

function bnEquals(b) {
    return this.compareTo(b) == 0
}

function bnMin(b) {
    return this.compareTo(b) < 0 ? this : b
}

function bnMax(b) {
    return this.compareTo(b) > 0 ? this : b
}

function bnpBitwiseTo(c, h, e) {
    var d, g, b = Math.min(c.t, this.t);
    for (d = 0; d < b; ++d) {
        e[d] = h(this[d], c[d])
    }
    if (c.t < this.t) {
        g = c.s & this.DM;
        for (d = b; d < this.t; ++d) {
            e[d] = h(this[d], g)
        }
        e.t = this.t
    } else {
        g = this.s & this.DM;
        for (d = b; d < c.t; ++d) {
            e[d] = h(g, c[d])
        }
        e.t = c.t
    }
    e.s = h(this.s, c.s);
    e.clamp()
}

function op_and(a, b) {
    return a & b
}

function bnAnd(b) {
    var c = nbi();
    this.bitwiseTo(b, op_and, c);
    return c
}

function op_or(a, b) {
    return a | b
}

function bnOr(b) {
    var c = nbi();
    this.bitwiseTo(b, op_or, c);
    return c
}

function op_xor(a, b) {
    return a ^ b
}

function bnXor(b) {
    var c = nbi();
    this.bitwiseTo(b, op_xor, c);
    return c
}

function op_andnot(a, b) {
    return a & ~b
}

function bnAndNot(b) {
    var c = nbi();
    this.bitwiseTo(b, op_andnot, c);
    return c
}

function bnNot() {
    var b = nbi();
    for (var a = 0; a < this.t; ++a) {
        b[a] = this.DM & ~this[a]
    }
    b.t = this.t;
    b.s = ~this.s;
    return b
}

function bnShiftLeft(b) {
    var a = nbi();
    if (b < 0) {
        this.rShiftTo(-b, a)
    } else {
        this.lShiftTo(b, a)
    }
    return a
}

function bnShiftRight(b) {
    var a = nbi();
    if (b < 0) {
        this.lShiftTo(-b, a)
    } else {
        this.rShiftTo(b, a)
    }
    return a
}

function lbit(a) {
    if (a == 0) {
        return -1
    }
    var b = 0;
    if ((a & 65535) == 0) {
        a >>= 16;
        b += 16
    }
    if ((a & 255) == 0) {
        a >>= 8;
        b += 8
    }
    if ((a & 15) == 0) {
        a >>= 4;
        b += 4
    }
    if ((a & 3) == 0) {
        a >>= 2;
        b += 2
    }
    if ((a & 1) == 0) {
        ++b
    }
    return b
}

function bnGetLowestSetBit() {
    for (var a = 0; a < this.t; ++a) {
        if (this[a] != 0) {
            return a * this.DB + lbit(this[a])
        }
    }
    if (this.s < 0) {
        return this.t * this.DB
    }
    return -1
}

function cbit(a) {
    var b = 0;
    while (a != 0) {
        a &= a - 1;
        ++b
    }
    return b
}

function bnBitCount() {
    var c = 0, a = this.s & this.DM;
    for (var b = 0; b < this.t; ++b) {
        c += cbit(this[b] ^ a)
    }
    return c
}

function bnTestBit(b) {
    var a = Math.floor(b / this.DB);
    if (a >= this.t) {
        return this.s != 0
    }
    return (this[a] & 1 << b % this.DB) != 0
}

function bnpChangeBit(c, b) {
    var a = BigInteger.ONE.shiftLeft(c);
    this.bitwiseTo(a, b, a);
    return a
}

function bnSetBit(a) {
    return this.changeBit(a, op_or)
}

function bnClearBit(a) {
    return this.changeBit(a, op_andnot)
}

function bnFlipBit(a) {
    return this.changeBit(a, op_xor)
}

function bnpAddTo(d, f) {
    var e = 0, g = 0, b = Math.min(d.t, this.t);
    while (e < b) {
        g += this[e] + d[e];
        f[e++] = g & this.DM;
        g >>= this.DB
    }
    if (d.t < this.t) {
        g += d.s;
        while (e < this.t) {
            g += this[e];
            f[e++] = g & this.DM;
            g >>= this.DB
        }
        g += this.s
    } else {
        g += this.s;
        while (e < d.t) {
            g += d[e];
            f[e++] = g & this.DM;
            g >>= this.DB
        }
        g += d.s
    }
    f.s = g < 0 ? -1 : 0;
    if (g > 0) {
        f[e++] = g
    } else {
        if (g < -1) {
            f[e++] = this.DV + g
        }
    }
    f.t = e;
    f.clamp()
}

function bnAdd(b) {
    var c = nbi();
    this.addTo(b, c);
    return c
}

function bnSubtract(b) {
    var c = nbi();
    this.subTo(b, c);
    return c
}

function bnMultiply(b) {
    var c = nbi();
    this.multiplyTo(b, c);
    return c
}

function bnSquare() {
    var a = nbi();
    this.squareTo(a);
    return a
}

function bnDivide(b) {
    var c = nbi();
    this.divRemTo(b, c, null);
    return c
}

function bnRemainder(b) {
    var c = nbi();
    this.divRemTo(b, null, c);
    return c
}

function bnDivideAndRemainder(b) {
    var d = nbi(), c = nbi();
    this.divRemTo(b, d, c);
    return new Array(d, c)
}

function bnpDMultiply(a) {
    this[this.t] = this.am(0, a - 1, this, 0, 0, this.t);
    ++this.t;
    this.clamp()
}

function bnpDAddOffset(b, a) {
    if (b == 0) {
        return
    }
    while (this.t <= a) {
        this[this.t++] = 0
    }
    this[a] += b;
    while (this[a] >= this.DV) {
        this[a] -= this.DV;
        if (++a >= this.t) {
            this[this.t++] = 0
        }
        ++this[a]
    }
}

function NullExp() {
}

function nNop(a) {
    return a
}

function nMulTo(a, c, b) {
    a.multiplyTo(c, b)
}

function nSqrTo(a, b) {
    a.squareTo(b)
}

NullExp.prototype.convert = nNop;
NullExp.prototype.revert = nNop;
NullExp.prototype.mulTo = nMulTo;
NullExp.prototype.sqrTo = nSqrTo;

function bnPow(a) {
    return this.exp(a, new NullExp())
}

function bnpMultiplyLowerTo(b, f, e) {
    var d = Math.min(this.t + b.t, f);
    e.s = 0;
    e.t = d;
    while (d > 0) {
        e[--d] = 0
    }
    var c;
    for (c = e.t - this.t; d < c; ++d) {
        e[d + this.t] = this.am(0, b[d], e, d, 0, this.t)
    }
    for (c = Math.min(b.t, f); d < c; ++d) {
        this.am(0, b[d], e, d, 0, f - d)
    }
    e.clamp()
}

function bnpMultiplyUpperTo(b, e, d) {
    --e;
    var c = d.t = this.t + b.t - e;
    d.s = 0;
    while (--c >= 0) {
        d[c] = 0
    }
    for (c = Math.max(e - this.t, 0); c < b.t; ++c) {
        d[this.t + c - e] = this.am(e - c, b[c], d, 0, 0, this.t + c - e)
    }
    d.clamp();
    d.drShiftTo(1, d)
}

function Barrett(a) {
    this.r2 = nbi();
    this.q3 = nbi();
    BigInteger.ONE.dlShiftTo(2 * a.t, this.r2);
    this.mu = this.r2.divide(a);
    this.m = a
}

function barrettConvert(a) {
    if (a.s < 0 || a.t > 2 * this.m.t) {
        return a.mod(this.m)
    } else {
        if (a.compareTo(this.m) < 0) {
            return a
        } else {
            var b = nbi();
            a.copyTo(b);
            this.reduce(b);
            return b
        }
    }
}

function barrettRevert(a) {
    return a
}

function barrettReduce(a) {
    a.drShiftTo(this.m.t - 1, this.r2);
    if (a.t > this.m.t + 1) {
        a.t = this.m.t + 1;
        a.clamp()
    }
    this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
    this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
    while (a.compareTo(this.r2) < 0) {
        a.dAddOffset(1, this.m.t + 1)
    }
    a.subTo(this.r2, a);
    while (a.compareTo(this.m) >= 0) {
        a.subTo(this.m, a)
    }
}

function barrettSqrTo(a, b) {
    a.squareTo(b);
    this.reduce(b)
}

function barrettMulTo(a, c, b) {
    a.multiplyTo(c, b);
    this.reduce(b)
}

Barrett.prototype.convert = barrettConvert;
Barrett.prototype.revert = barrettRevert;
Barrett.prototype.reduce = barrettReduce;
Barrett.prototype.mulTo = barrettMulTo;
Barrett.prototype.sqrTo = barrettSqrTo;

function bnModPow(q, f) {
    var o = q.bitLength(), h, b = nbv(1), v;
    if (o <= 0) {
        return b
    } else {
        if (o < 18) {
            h = 1
        } else {
            if (o < 48) {
                h = 3
            } else {
                if (o < 144) {
                    h = 4
                } else {
                    if (o < 768) {
                        h = 5
                    } else {
                        h = 6
                    }
                }
            }
        }
    }
    if (o < 8) {
        v = new Classic(f)
    } else {
        if (f.isEven()) {
            v = new Barrett(f)
        } else {
            v = new Montgomery(f)
        }
    }
    var p = new Array(), d = 3, s = h - 1, a = (1 << h) - 1;
    p[1] = v.convert(this);
    if (h > 1) {
        var A = nbi();
        v.sqrTo(p[1], A);
        while (d <= a) {
            p[d] = nbi();
            v.mulTo(A, p[d - 2], p[d]);
            d += 2
        }
    }
    var l = q.t - 1, x, u = true, c = nbi(), y;
    o = nbits(q[l]) - 1;
    while (l >= 0) {
        if (o >= s) {
            x = q[l] >> o - s & a
        } else {
            x = (q[l] & (1 << o + 1) - 1) << s - o;
            if (l > 0) {
                x |= q[l - 1] >> this.DB + o - s
            }
        }
        d = h;
        while ((x & 1) == 0) {
            x >>= 1;
            --d
        }
        if ((o -= d) < 0) {
            o += this.DB;
            --l
        }
        if (u) {
            p[x].copyTo(b);
            u = false
        } else {
            while (d > 1) {
                v.sqrTo(b, c);
                v.sqrTo(c, b);
                d -= 2
            }
            if (d > 0) {
                v.sqrTo(b, c)
            } else {
                y = b;
                b = c;
                c = y
            }
            v.mulTo(c, p[x], b)
        }
        while (l >= 0 && (q[l] & 1 << o) == 0) {
            v.sqrTo(b, c);
            y = b;
            b = c;
            c = y;
            if (--o < 0) {
                o = this.DB - 1;
                --l
            }
        }
    }
    return v.revert(b)
}

function bnGCD(c) {
    var b = this.s < 0 ? this.negate() : this.clone();
    var h = c.s < 0 ? c.negate() : c.clone();
    if (b.compareTo(h) < 0) {
        var e = b;
        b = h;
        h = e
    }
    var d = b.getLowestSetBit(), f = h.getLowestSetBit();
    if (f < 0) {
        return b
    }
    if (d < f) {
        f = d
    }
    if (f > 0) {
        b.rShiftTo(f, b);
        h.rShiftTo(f, h)
    }
    while (b.signum() > 0) {
        if ((d = b.getLowestSetBit()) > 0) {
            b.rShiftTo(d, b)
        }
        if ((d = h.getLowestSetBit()) > 0) {
            h.rShiftTo(d, h)
        }
        if (b.compareTo(h) >= 0) {
            b.subTo(h, b);
            b.rShiftTo(1, b)
        } else {
            h.subTo(b, h);
            h.rShiftTo(1, h)
        }
    }
    if (f > 0) {
        h.lShiftTo(f, h)
    }
    return h
}

function bnpModInt(e) {
    if (e <= 0) {
        return 0
    }
    var c = this.DV % e, b = this.s < 0 ? e - 1 : 0;
    if (this.t > 0) {
        if (c == 0) {
            b = this[0] % e
        } else {
            for (var a = this.t - 1; a >= 0; --a) {
                b = (c * b + this[a]) % e
            }
        }
    }
    return b
}

function bnModInverse(f) {
    var j = f.isEven();
    if (this.isEven() && j || f.signum() == 0) {
        return BigInteger.ZERO
    }
    var i = f.clone(), h = this.clone();
    var g = nbv(1), e = nbv(0), l = nbv(0), k = nbv(1);
    while (i.signum() != 0) {
        while (i.isEven()) {
            i.rShiftTo(1, i);
            if (j) {
                if (!g.isEven() || !e.isEven()) {
                    g.addTo(this, g);
                    e.subTo(f, e)
                }
                g.rShiftTo(1, g)
            } else {
                if (!e.isEven()) {
                    e.subTo(f, e)
                }
            }
            e.rShiftTo(1, e)
        }
        while (h.isEven()) {
            h.rShiftTo(1, h);
            if (j) {
                if (!l.isEven() || !k.isEven()) {
                    l.addTo(this, l);
                    k.subTo(f, k)
                }
                l.rShiftTo(1, l)
            } else {
                if (!k.isEven()) {
                    k.subTo(f, k)
                }
            }
            k.rShiftTo(1, k)
        }
        if (i.compareTo(h) >= 0) {
            i.subTo(h, i);
            if (j) {
                g.subTo(l, g)
            }
            e.subTo(k, e)
        } else {
            h.subTo(i, h);
            if (j) {
                l.subTo(g, l)
            }
            k.subTo(e, k)
        }
    }
    if (h.compareTo(BigInteger.ONE) != 0) {
        return BigInteger.ZERO
    }
    if (k.compareTo(f) >= 0) {
        return k.subtract(f)
    }
    if (k.signum() < 0) {
        k.addTo(f, k)
    } else {
        return k
    }
    if (k.signum() < 0) {
        return k.add(f)
    } else {
        return k
    }
}

var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];

function bnIsProbablePrime(e) {
    var d, b = this.abs();
    if (b.t == 1 && b[0] <= lowprimes[lowprimes.length - 1]) {
        for (d = 0; d < lowprimes.length; ++d) {
            if (b[0] == lowprimes[d]) {
                return true
            }
        }
        return false
    }
    if (b.isEven()) {
        return false
    }
    d = 1;
    while (d < lowprimes.length) {
        var a = lowprimes[d], c = d + 1;
        while (c < lowprimes.length && a < lplim) {
            a *= lowprimes[c++]
        }
        a = b.modInt(a);
        while (d < c) {
            if (a % lowprimes[d++] == 0) {
                return false
            }
        }
    }
    return b.millerRabin(e)
}

function bnpMillerRabin(f) {
    var g = this.subtract(BigInteger.ONE);
    var c = g.getLowestSetBit();
    if (c <= 0) {
        return false
    }
    var h = g.shiftRight(c);
    f = f + 1 >> 1;
    if (f > lowprimes.length) {
        f = lowprimes.length
    }
    var b = nbi();
    for (var e = 0; e < f; ++e) {
        b.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
        var l = b.modPow(h, this);
        if (l.compareTo(BigInteger.ONE) != 0 && l.compareTo(g) != 0) {
            var d = 1;
            while (d++ < c && l.compareTo(g) != 0) {
                l = l.modPowInt(2, this);
                if (l.compareTo(BigInteger.ONE) == 0) {
                    return false
                }
            }
            if (l.compareTo(g) != 0) {
                return false
            }
        }
    }
    return true
}

BigInteger.prototype.chunkSize = bnpChunkSize;
BigInteger.prototype.toRadix = bnpToRadix;
BigInteger.prototype.fromRadix = bnpFromRadix;
BigInteger.prototype.fromNumber = bnpFromNumber;
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
BigInteger.prototype.changeBit = bnpChangeBit;
BigInteger.prototype.addTo = bnpAddTo;
BigInteger.prototype.dMultiply = bnpDMultiply;
BigInteger.prototype.dAddOffset = bnpDAddOffset;
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
BigInteger.prototype.modInt = bnpModInt;
BigInteger.prototype.millerRabin = bnpMillerRabin;
BigInteger.prototype.clone = bnClone;
BigInteger.prototype.intValue = bnIntValue;
BigInteger.prototype.byteValue = bnByteValue;
BigInteger.prototype.shortValue = bnShortValue;
BigInteger.prototype.signum = bnSigNum;
BigInteger.prototype.toByteArray = bnToByteArray;
BigInteger.prototype.equals = bnEquals;
BigInteger.prototype.min = bnMin;
BigInteger.prototype.max = bnMax;
BigInteger.prototype.and = bnAnd;
BigInteger.prototype.or = bnOr;
BigInteger.prototype.xor = bnXor;
BigInteger.prototype.andNot = bnAndNot;
BigInteger.prototype.not = bnNot;
BigInteger.prototype.shiftLeft = bnShiftLeft;
BigInteger.prototype.shiftRight = bnShiftRight;
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
BigInteger.prototype.bitCount = bnBitCount;
BigInteger.prototype.testBit = bnTestBit;
BigInteger.prototype.setBit = bnSetBit;
BigInteger.prototype.clearBit = bnClearBit;
BigInteger.prototype.flipBit = bnFlipBit;
BigInteger.prototype.add = bnAdd;
BigInteger.prototype.subtract = bnSubtract;
BigInteger.prototype.multiply = bnMultiply;
BigInteger.prototype.divide = bnDivide;
BigInteger.prototype.remainder = bnRemainder;
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
BigInteger.prototype.modPow = bnModPow;
BigInteger.prototype.modInverse = bnModInverse;
BigInteger.prototype.pow = bnPow;
BigInteger.prototype.gcd = bnGCD;
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
BigInteger.prototype.square = bnSquare;
